<?php
require_once("../../../config.inc.php");
$isReloadable = true;
require_once("../../../app/_inc/include.php");
require_once("domainFunction.php");

$errMsg = "";
if(sxREQUEST("reqtype") == "delete") {
	$sSQL = "DELETE FROM domain_value WHERE domain='".sxRAS('dom')."' and value = '".sxRAS('val')."'";
	$objSDAO->exec($sSQL);
	$objUser->setHistoryVar(array('reqtype'=>''));
}
//get values
$sSQL = "SELECT dv.*, d.description AS dom_des, d.domain FROM domain d " .
		" LEFT JOIN domain_value dv ON dv.domain = d.domain " .
		" WHERE d.domain='".sxREQ('dom')."' ORDER BY dv.sequence";
$objSDAO->query($sSQL, "val");
$row = $objSDAO->fetch("val");
$aOpz = array("kMenu"=>'dam.dom', "isReloadable"=>$isReloadable);
echo(headerHTML($aOpz));
?>
<script language="JavaScript" type="text/javascript" src="../../_jsc/form.js"></script>  
<script language="JavaScript" type="text/javascript">
</script>
  
<?php
echo(bodyHTML($aOpz));
//output comandi
echo("<table class=\"tabl01\" width=\"100%\" cellpadding=\"3\" cellspacing=\"2\">\n");

$aCmd = array("ins"=>array("pag"=>"domainValueIns.php?dom=".sxREQ('dom'),
										"title"=>_t("add new value"),
										"text"=>_t("new value"),
										"perm"=>"newdom"),
					"back"=>array("pag"=>$objUser->getHistory(-1, false),
										"title"=>$objUser->getHistoryText(-1),
										"text"=>$objUser->getHistoryText(-1))
					);
echo(commandsHTML($aCmd));	
echo("<table class=\"tabl01\" width=\"100%\" cellpadding=\"3\" cellspacing=\"2\">\n");
echo("<tr>" .
		"<td class=\"labl01\" colspan=\"2\">Domain</td>" .
		"<td class=\"text01\" colspan=\"3\">".$row['domain'].' - '.$row['dom_des']."</td>" .
	"</tr>\n");
echo("<tr>" .
		"<td class=\"titl01\" colspan=\"5\">List of values</tr>\n");
echo("<tr>" .
		"<td class=\"tabh01\" width=\"1%\">&nbsp;</td>" .
		"<td class=\"tabh01\" width=\"19%\">"._t("Value")."</td>" .
		"<td class=\"tabh01\" width=\"40%\">"._t("Description")."</td>" .
		"<td class=\"tabh01\" width=\"39%\">"._t("Note")."</td>" .
		"<td class=\"tabh01\" width=\"1%\">"._t("Seq.")."</td>" .
	"</tr>\n");
while($row and $row['value'] != ''){
	echo("<tr>" .
		"<td class=\"text01\"><a href='domainValueList.php?reqtype=delete&dom=".sxREQ('dom')."&val=".
		urlencode($row["value"])."&xsn=".XSN."' class='text01'>" .
		"<img src='".SERVER_URL_ROOT."/app/_img/b_drop.png' border='0'></a></td>" .
		"<td class=\"text01\"><a href='domainValueMod.php?dom=".sxREQ('dom')."&val=".
		urlencode($row["value"])."&xsn=".XSN."' class='text01'>" .sxHE($row["value"])."</a></td>" .
		"<td class=\"text01\">".sxHE($row["description"])."</td>" .
		"<td class=\"text01\">".sxHE($row["note"])."</td>" .
		"<td class=\"text01\">".sxHE($row["sequence"])."</td>" .
	"</tr>\n");
	$row = $objSDAO->fetch("val");
}	
echo("</table>");

echo(commandsHTML($aCmd));
echo("</form>\n");
echo("</td>\n</tr>\n</table>\n");
echo(footerHTML());


?>
